cmake_minimum_required(VERSION 3.16.3)
project ( systemtraydaemon )

#判断编译器类型,如果是gcc编译器,则在编译选项中加入c++11支持
if(CMAKE_COMPILER_IS_GNUCXX)
   set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
   message(STATUS "optional:-std=c++11")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
   set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
find_package(Qt5 COMPONENTS Core Gui Qml Quick Widgets Network REQUIRED)
find_package(Qt5DBus REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(dbusmenu-qt5 REQUIRED)
pkg_check_modules(Gsetting REQUIRED gsettings-qt)
include_directories(${Gsetting_INCLUDE_DIRS})
#set(LIBRARIES
#    ${Gsetting_LIBRARIES}
#    -lukui-log4qt
#)



#添加子目录
set(SUB_LIB
    statusnotifierwatcher
    xembedtosniproxy
#    libukuitraymanager
)
include_directories( statusnotifierwatcher xembedtosniproxy )
add_subdirectory( statusnotifierwatcher )
add_subdirectory( xembedtosniproxy )
add_subdirectory( libukuitraymanager )

# 生成可执行文件
set(HEADERS
    protocolmanager.h
    statusnotifieritemsource.h
    statusnotifiermodel.h
#    libukuitraymanager/systemtraymanager.h
    systemtraydaemonservice.h
)
set(SOURCES
    main.cpp
    protocolmanager.cpp
    statusnotifieritemsource.cpp
    statusnotifiermodel.cpp
#    libukuitraymanager/systemtraymanager.cpp
    systemtraydaemonservice.cpp
)
add_executable( ${PROJECT_NAME}
    ${HEADERS}
    ${SOURCES}
)
#target_include_directories( demo
#    PRIVATE
#    ${PROJECT_SOURCE_DIR}/include
#)
# 链接对象库
target_link_libraries( ${PROJECT_NAME}
    PRIVATE
    statusnotifierwatcher
    xembedtosniproxy
    Qt5::Widgets
    Qt5::DBus
    xcb
    dbusmenu-qt5
    ${Gsetting_LIBRARIES}
    -lukui-log4qt
)

##########################
### 生成动态库
#set(LIB_NAME ukuitraymanager)
#set(LIB_SOURCES
#    libukuitraymanager/systemtraymanager.cpp
#)
#add_library( ${LIB_NAME} SHARED
#    ${LIB_SOURCES}
#)
## 添加头文件目录
#target_include_directories( ${LIB_NAME}
#   PUBLIC
##       ${PROJECT_SOURCE_DIR}/include
#       libukuitraymanager/systemtraymanager.h
#)
## 链接对象库
#target_link_libraries( ${LIB_NAME}
#   PRIVATE
#   Qt5::Widgets
#   Qt5::DBus
#   dbusmenu-qt5
#   ${SUB_LIB}
#)



